home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
- PRODUCT : Paradox NUMBER : 789
- VERSION : 3.0 & up
- OS : DOS
- DATE : August 26, 1991 PAGE : 1/4
-
- TITLE : Calculating Percent of Total in a Report
-
-
-
-
- In order to do percentage totals, such as the value in the
- Quantity field for the current record divided by the sum of all
- the values in the Quantity Column, your computer must know both
- values in the division. In Paradox (or other software) terms
- this means the sum of an entire group or column must be known at
- print time. The column total is determined by reading all of the
- records while accumulating the total and then holding that total
- in memory storage for later use. At print time a second pass or
- read of the records is done listing data according to the
- report's design. We call this process of reading once for
- accumulators and a second time for printing a "two-pass report".
- Paradox does only "one-pass" reporting, formatting output and
- printing records as it goes.
-
- There are a number of alternative methods to calculate the
- percent of the total of either a record value or group summary
- value. We will cover two different methods here. Both methods
- are available in Paradox 3.5. However only the query method is
- available in Paradox 3.0x. The first method is based on a
- calculation held in a new field in the table. The second is
- based on PAL report features added in Paradox 3.5.
-
- For both of these methods lets assume the following table
- structure:
-
- Table Name: TablName
- Field 1 A10*
- Field 2 A10
- Field 3 D
- Field 4 $
-
- For this example we want to have the percent of total of each
- record and of each group based on Field 3 (date field). We will
- use Report R1 for this table.
-
- The basic structure of the report is:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Paradox NUMBER : 789
- VERSION : 3.0 & up
- OS : DOS
- DATE : August 26, 1991 PAGE : 2/4
-
- TITLE : Calculating Percent of Total in a Report
-
-
-
-
- ƒƒ page ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒƒ group Field 3 range=month ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒƒƒ table ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- Field 1 Field 2 Field 3 Field 4 Pct. of Total
- ---------- ---------- -------- ------------ -------------
- AAAAAAAAAA AAAAAAAAAA mm/dd/yy (999,999.99) (999.99)%
- ƒƒƒƒ table ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ----------- ---------
- total for month: (999,999.99) (999.99)%
-
- ƒƒƒ group Field 3 range=month ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒ page ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- Overall total: (999,999,999.99)
- ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ
-
- First Method
- ----- ------
- The first method requires an additional field in the table.
- Therefore the structure will now be:
-
- Table Name: TablName
- Field 1 A10*
- Field 2 A10
- Field 3 D
- Field 4 $
- Total N
-
- The percentage fields in the report will both be calculated
- fields. The first calculated field in the Table band will be:
- [Field 4]/[Total]*100.
-
- The calculation in the group footer band will be:
- SUM([Field 4], Group)/[Total]*100
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Paradox NUMBER : 789
- VERSION : 3.0 & up
- OS : DOS
- DATE : August 26, 1991 PAGE : 3/4
-
- TITLE : Calculating Percent of Total in a Report
-
-
-
-
- We will use a query to calculate the total. The first query for
- this table will be:
-
- QUERY
-
- TablName | Field 4 |
- | Calc Sum |
-
- ENDQUERY
-
- The above query will produce a one field one record answer table.
- We will use a second query (which uses two tables in one query)
- to place the result of the answer table into the report table:
-
- QUERY
-
- Tablname | Total |
- | changeto _a |
-
- Answer | Sum of Field 4 |
- | _a |
-
- ENDQUERY
-
- This will provide us with the necessary data in the table and
- allow the report to take place. For a variation on this method,
- see Technical Information Bulletin #539. It has information on
- how to place variables in a report with a lookup table.
-
- Second Method
- ------ ------
-
- The second method is only available in Paradox 3.5. It uses a
- PAL variable in the report specification. It also does not
- require an additional field in the table. You must define the
- variable before the report is printed. The following script will
- calculate the total and place it into the variable 'Totl'.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : Paradox NUMBER : 789
- VERSION : 3.0 & up
- OS : DOS
- DATE : August 26, 1991 PAGE : 4/4
-
- TITLE : Calculating Percent of Total in a Report
-
-
-
-
- ;SCRIPT BEGINS
-
- CLEAR
- CLEARALL
- Totl=CSUM("TablName", "Field 4") ; Calculates sum of Field 4
- REPORT "TablName" "1" ; Prints report 1 for TablName
-
- ;SCRIPT ENDS
-
- The calculated fields will be held as Alphanumeric fields. We
- will use Report R1 for this table. The basic structure of the
- report is:
-
- ƒƒ page ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒƒ group Field 3 range=month ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒƒƒ table ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- Field 1 Field 2 Field 3 Field 4 Pct. of Total
- ---------- ---------- -------- ------------ -------------
- AAAAAAAAAA AAAAAAAAAA mm/dd/yy (999,999.99) AAAAAAAAA%
- ƒƒƒƒ table ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ------------ ----------
- total for month: (999,999.99) AAAAAAAAA%
-
- ƒƒƒ group Field 3 range=month ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- ƒƒ page ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
- Overall total: (999,999,999.99)
- ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕ
-
- The percentage fields in the report will both be calculated
- fields. The first calculated field will be in the Table band.
- The calculation will be: [Field 4]/Totl * 100
-
- The calculation in the group footer band will be:
- SUM([Field 4], Group)/Totl * 100
-
- These methods will also work for the percent of a total count of
- records.
-
-
-
-
-
-
-
-
-
-
-
-
-